import { isValidKey } from './SvgIcon/type.ts'

import SvgIcon from './SvgIcon/index.vue'

// elementUI的icon
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const allGlobalComponent = { SvgIcon }

export default {
  install(app: any) {
    Object.keys(allGlobalComponent).forEach((key) => {
      if (isValidKey(key, allGlobalComponent)) {
        app.component(key, allGlobalComponent[key])
      }
    })

    // 将elementUI的icon注册
    for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
      app.component(key, component)
    }
  },
}
